home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DSIIC2.ARJ / L_SCRN2.C < prev    next >
C/C++ Source or Header  |  1991-07-15  |  2KB  |  92 lines

  1. /* Copyright (c) James L. Pinson 1990,1991  */
  2.  
  3. /**********************   L_SCRN2.C    ***************************/
  4.  
  5. #include "mydef.h"
  6. #include <dos.h>
  7.  
  8.  
  9. /*****************************************************************
  10.  
  11.  Usage: void wherexy(int *x,int *y);
  12.  
  13.  Call with address of x and y  "wherexy(&x,&y);"
  14.  
  15.  Returns the current address of the cursor. x=column y=row
  16.  Value is relative to active window.  1,1 is upper left corner.
  17.  
  18. *****************************************************************/
  19.  
  20. void wherexy(int *x,int *y)
  21. {
  22. extern struct  screen_structure scr;
  23. extern struct window_structure w[];
  24.  
  25.    union REGS regs;
  26.  
  27.    regs.h.ah = 3;  /* read cursor  function*/
  28.  
  29.    regs.h.bh = scr.page;      /* page to read */
  30.  
  31.    int86(0x10, ®s,®s);  /* do interrupt */
  32.  
  33.    /* get x from dl and adjust for window */
  34.    *x=( regs.h.dl +2-scr.left); 
  35.  
  36.    /* get y from dh and adjust for window */
  37.    *y= (regs.h.dh +2-scr.top);    
  38. }
  39.  
  40.  
  41. /*****************************************************************
  42.  
  43.  Usage: void readxy(char *ch,char *attr);
  44.  
  45.  Call with address of ch and attr  "readxy(&ch,&attr);"
  46.  
  47.  Returns with ch= the character under the cursor.
  48.  attr= text attribute under the cursor.
  49.  
  50. *****************************************************************/
  51.  
  52. void readxy(char *ch,char *attr)
  53. {
  54. extern struct screen_structure  scr;
  55.  
  56.    union REGS regs;
  57.  
  58.    regs.h.ah = 8;         /* read char function */
  59.    regs.h.bh = scr.page;  /* page number to read */
  60.  
  61.    int86(0x10, ®s,®s); /* do interrupt */
  62.  
  63.    *ch = regs.h.al;         /* get character from al */
  64.    *attr = regs.h.ah;       /* get attribute from ah */
  65. }
  66.  
  67.  
  68. /*****************************************************************
  69.  
  70.  Usage: void what_cursor(int *start,int *end);
  71.  
  72.  Call with address of start and end  "what_cursor(&start,&end);"
  73.  
  74.  Returns the starting and ending scan lines for the cursor.
  75.  
  76. *****************************************************************/
  77.  
  78. void what_cursor(int *start, int *end)
  79. {
  80. extern struct screen_structure scr;
  81.  
  82. union REGS regs;
  83.  
  84.  regs.h.ah=0x3;       /* read cursor */
  85.  regs.h.bh=scr.page;  /* must tell it what page for color systems */
  86.  
  87.  int86(0x10,®s,®s);  /* do interrupt */
  88.  
  89.  /* starting line in ch, ending line in cl */
  90.  *start=regs.h.ch;  *end=regs.h.cl;
  91. }
  92.